<?
include_once('conn.php');
	if($_POST or $_GET){
		$value=$_POST==TRUE?$_POST:$_GET;
		errorchars($value);
		}
		//
include_once('include/browser_class.php');
$temp_name=htmlspecialchars($_POST['adminname']);
$temp_pw=htmlspecialchars($_POST['adminpw']);
if ($_POST){
	ob_start(); 
	setcookie("adminname",addslashes($temp_name),time()+21600);
	setcookie("adminpw",md5(addslashes($temp_pw)),time()+21600);
header("Location: ./admin_main.php");
exit;
}
//


if(isset($_GET[out])){
		setcookie("adminname",'');
	setcookie("adminpw", '');
	header("Location: ./admin_index.php");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo systemname;?></title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
	color: #333;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
        <script type="text/javascript">
            function myfun()
            {
                var cha1;
                cha1=document.myform.adminname.value;
                if(cha1=="")
                {
                    alert("姓名不可为空!");
                    return false;
                }
				var cha2;
				cha2=document.myform.adminpw.value;
				if(cha2=="")
				{
				    alert("密码不能为空");
				    return false;
				}
			}
        </script>
</head>

<body>
<div style="background:url(images/t_bg.gif) repeat-x; height:125px;"><img style="margin-left:10px; float:left;" src="images/ttfjpg.php?t=分销管理系统&bg=logobg.jpg&z=20&x=5&y=60&r=255&b=255&g=255"  /></div>
<form name="myform" method="POST" onSubmit="return myfun()">
  <table width="500" height="128" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="2"  align="center"><?
      echo check_browser();
	  ?></td>
    </tr>
    <tr>
      <td colspan="2"  align="center">后台管理</td>
    </tr>
    <?
	$ex_time = mktime(date("H")-1,date("i"),date("s"),date("m"),date("d"),date("Y"));
    $ip = $db->select("SELECT ip,datetime FROM `".tablepre."save` where ip = '".$clientIp."' and UNIX_TIMESTAMP(datetime) > ".$ex_time." ");
	//datetime+
	if($ip[0][0]==TRUE){
		count($ip);
	?>
        <tr>
      <td colspan="2"  align="center">您还有<? echo 5-count($ip);?>次机会尝试登陆</td>
    </tr>
    
    <? }
	if(count($ip)<5 or count($ip)==null){
	?>
    <tr>
      <td width="224"  align="right"><p>用户名&nbsp;&nbsp;</p>      </td>
      <td width="276"><p>
        <input type="text" name="adminname" /> 
      </p>      </td>
    </tr>
    <tr>
      <td align="right">密码&nbsp;&nbsp;</td>
      <td><input type="password" name="adminpw" /></td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td><input type="submit" value="进入" /></td>
    </tr>
    <? }else{?>
        <tr>
      <td colspan="2"  align="center">请一个小时后重试</td>
    </tr>
    <? }?>
  </table>
</form>
</body>
</html>
